package designMode.compositePattern;

import java.util.Iterator;

/**
 * @author LIBOFEI
 * @ClassName Print
 * @description
 * @date 2020/6/28 14:11
 * @Version 1.0
 **/
public class Print {

    private MenuComponent menuComponent;

    public Print(MenuComponent allMenu){
        this.menuComponent = allMenu;
    }

    public void printMenu(){
        menuComponent.print();
    }

    public void printMenuByIterator(){
        Iterator<MenuComponent> iterator = menuComponent.createIterator();
        while(iterator.hasNext()){
            MenuComponent menuComponent = iterator.next();
            menuComponent.print();
        }
    }
}
